package cqut.wys.domain;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;

/**
 * @author wuyoushan@zbj.com
 * @date 2017/2/23.
 */
@CacheConfig(cacheNames = "users")
public interface UserRepository extends JpaRepository<User, Long> {

    //key使用函数的第一个参数作为缓存的key值
    //缓存兑现是我条件
    @Cacheable(key = "#p0", condition = "#p0.length() < 10")
    User findByName(String name);
}
